package com.dyc.caradvertisting.ui.fmt.first.child;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.dyc.caradvertisting.R;
import com.dyc.caradvertisting.api.ClientService;
import com.dyc.caradvertisting.bean.ClientLogin;
import com.google.gson.Gson;
import com.njh.tools.api.manager.ServiceManager;
import com.njh.tools.base.BaseFragment;
import com.njh.tools.base.util.RxSchedulers;
import com.njh.tools.view.CountDownButton;

import butterknife.BindView;
import butterknife.ButterKnife;
import rx.Observer;

/**
 * 首页
 */
public class FirstHomeFragment extends BaseFragment {

    @BindView(R.id.btn_doen)
    CountDownButton btnDoen;

    public FirstHomeFragment() {
        // Required empty public constructor
    }

    // TODO: Rename and change types and number of parameters
    public static FirstHomeFragment newInstance() {
        FirstHomeFragment fragment = new FirstHomeFragment();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    public int getLayoutId() {
        return R.layout.fragment_first_home;
    }

    @Override
    public void initView(View baseView) {
        ButterKnife.bind(this, baseView);
        Gson gson=new Gson();
        String json=gson.toJson(new ClientLogin("18201893499","123123"));
        ServiceManager.create(ClientService.class)
                .userLogin("101",json , "788c3f031efb5c00c94ceb496a941b35", 1477969939 )
                .compose(RxSchedulers.io_main())
                .subscribe(new Observer<Object>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(Object o) {
                        Log.e("onNext", o.toString());
                    }
                });
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        ButterKnife.bind(this, rootView);
        return rootView;
    }
}
